package com.test;

import com.qf.dao.UsersDao;
import com.qf.dao.impl.UsersDaoImpl;
import com.qf.util.UsersDaoProxy;

import java.lang.reflect.Proxy;

/**
 * 2019/11/12
 * Administrator
 * spring_proxy
 * 面向对象面向君  不负代码不负卿
 */
public class Demo1 {
    public static void main(String[] args) {
  /*      UsersDao usersDao=new UsersDaoImpl();
        usersDao.a();*/
        UsersDao usersDao=new UsersDaoImpl();
        UsersDaoProxy usersDaoProxy = new UsersDaoProxy(usersDao);//用来生成usersDao的代理对象,参数是真实的对象
        Class[] classes=usersDao.getClass().getInterfaces();
        for (Class aClass : classes) {
            System.out.println(aClass+"...");
        }
        UsersDao daoproxy =(UsersDao)
                Proxy.newProxyInstance(usersDao.getClass().getClassLoader(), usersDao.getClass().getInterfaces(), usersDaoProxy);
        daoproxy.a();
    }
}
